package com.dcy.daily.service.service;

import com.dcy.daily.common.core.base.BaseService;
import com.dcy.daily.core.mapper.AccountMapper;
import com.dcy.daily.core.model.Account;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @author duanchunyu
 * @version 1.0.0
 * @createTime 2021年06月01日 14:25:00
 */
@Service
public class AccountService extends BaseService {

    @Autowired
    private AccountMapper accountMapper;

    @Cacheable(cacheNames = "CacheKey",keyGenerator = "keyGenerator")
    public Account getAccount(Integer id){
       return accountMapper.selectByPrimaryKey(id);
    }

    public Integer updateAccount(Account account){
        return accountMapper.updateByPrimaryKey(account);
    }

    public int insertAccount(Account account){
        return accountMapper.insert(account);
    }

    public List<Account> handlePageAccount(Integer pageNum, Integer pageSize){
        startPage(pageNum,pageSize,true);
        List<Account> allAccount = accountMapper.findAllAccount();
        return allAccount;
    }
    //@LogAspect
    public void transfer(){
        System.out.println("A:-1000");
        int z =  3/0;
        System.out.println("B:+1000");
    }

    public void transfer1(){
        System.out.println("A:-2000");
        System.out.println("B:+2000");
    }
}
